import os

class Config:
    # 基础配置
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'your-secret-key-here'
    BABEL_DEFAULT_LOCALE = 'zh'
    BABEL_TRANSLATION_DIRECTORIES = 'translations'
    
    # 数据库配置
    DATABASE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'packages.db')
    
    # 日志配置
    LOG_DIR = 'logs'
    LOG_FILE = os.path.join(LOG_DIR, 'app.log')
    LOG_LEVEL = 'INFO'
    LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    LOG_MAX_BYTES = 10000
    LOG_BACKUP_COUNT = 3
    
    # Session配置
    SESSION_TYPE = 'filesystem'
    PERMANENT_SESSION_LIFETIME = 3600  # 1小时
    
    # 支持的语言
    LANGUAGES = {
        'zh': '中文',
        'vi': 'Tiếng Việt',
        'th': 'ไทย'
    }

class DevelopmentConfig(Config):
    DEBUG = True
    
class ProductionConfig(Config):
    DEBUG = False
    # 生产环境特定配置
    LOG_LEVEL = 'ERROR'
    PERMANENT_SESSION_LIFETIME = 7200  # 2小时
    
    # 安全相关配置
    SESSION_COOKIE_SECURE = True
    SESSION_COOKIE_HTTPONLY = True
    REMEMBER_COOKIE_SECURE = True
    REMEMBER_COOKIE_HTTPONLY = True

# 根据环境变量选择配置
config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
} 